Let's
review the important design patterns that use SQL Azure. Before
designing your first cloud application, you should read this section to
become familiar with a few design options. Some of the advanced design
patterns explained in this article can also provide significant
business value, although they're more difficult to implement.
Note that for simplicity,
the diagrams in this section show only a direct connection to SQL
Azure. However, virtually all the patterns can be implemented using a
serviced connection through Azure services.
1. Direct Connection
The direct connection pattern, shown in Figure 1,
is perhaps the simplest form of connectivity to a SQL Azure database.
The consumer can be either an application located in a corporation's
network or a Windows Azure service connecting directly to the SQL Azure
database.
As simple as it is, this may
be one of the most widely used patterns, because it requires no special
configuration or advanced integration technique. For example, a
software as a service (SaaS) application may use this pattern; in this
case, the consumer is the web site hosted in Azure (or on any other
hosting provider). Alternatively, the consumer may be a smart device or
a phone accessing records in SQL Azure.
2. Smart Branching
The smart branching pattern (see Figure 2)
describes an application that contains sufficient logic to determine
whether the data it needs to load is located in the cloud or in a local
database. The logic to make this determination is either hardcoded in
the application or driven from a configuration file. It may also be
provided by a data access layer (DAL) engine that contains logic that
fetches data either a local or a cloud database.
One of the uses for smart
branching is to implement a form of caching in which the consumer
caches parts of its data locally or fetches it from a cloud database
whenever necessary. You can also use this pattern to implement a
disconnected mode to your application, in case Internet connectivity
becomes unavailable.
3. Transparent Branching
Whereas smart branching depends on the consumer (or one of its components) to determine whether data is local or in the cloud, transparent branching (see Figure 3)
removes this concern from the consumer. The consuming application no
longer depends on routing logic and becomes oblivious to the ultimate
location of the data.
This pattern is best
implemented by applications that are difficult to modify or for which
the cost of implementation is prohibitive. It can effectively be
implemented in the form of extended stored procedures that have the
knowledge to fetch data from a cloud data source. In essence, this
pattern implements a DAL at the database layer.